package com.itheima.web.controller;

import com.itheima.util.OssUtil;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;
import java.io.InputStream;

@RestController
@RequestMapping("/file")
public class FileController {


    @PostMapping("/upload")
    public String upload(MultipartFile multipartFile) throws IOException {
        String filename = multipartFile.getOriginalFilename();

            InputStream inputStream = multipartFile.getInputStream();

        String upload = OssUtil.upload(filename, inputStream);

        return upload;
    }
}
